#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <math.h>

int main()
{
	int t = 0;
	for (int i = 0; i <= 100000; i++)
	{
		int n = 1;
		int sum = 0;
		t = i;
		while (t>9)
		{
			n++;
			t /= 10;
		}
		t = i;
		while (t)
		{
			sum += pow(t % 10, n);
			t /= 10;
		}
		if (sum == i)
			printf("%d ", i);
	}
}